home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / public / radio / stations.pl < prev    next >
Perl Script  |  1994-08-01  |  854b  |  29 lines

  1. #!/usr/bin/perl
  2. ##
  3. ## Find radio stations
  4. ##
  5. ## (A small subset of the functionality of stations.py for now)
  6. ##
  7. ## Written by;  Jeff Beadles  jeff@onion.rain.com
  8. ##
  9. # this emulates #! processing on machines that don't support it.
  10. eval "exec /usr/bin/perl -S $0 $*"
  11.     if $running_under_some_shell_and_not_perl;
  12.  
  13. require 'sys/socket.ph';
  14.  
  15. ($name, $aliases, $proto) = getprotobyname('udp');
  16.  
  17. $this = pack('S n a4 x8' , &AF_INET, 54317, "\0\0\0\0");
  18.  
  19. socket(S, &AF_INET, &SOCK_DGRAM, $proto)  || die "socket: $!";
  20. bind(S, $this)                            || die "bind:   $!";
  21.  
  22. while (1) {
  23.     recv(S, $buf, 1024, 0) || die "recv:  $!\n";
  24.     chop($buf);
  25.     ($t_radio,$t_s,$t_name,$t_port,$t_xmit,$t_log,$t_age) = split(/:/,$buf,7);
  26.     print "Bogus message '$buf'\n" if ($t_radio ne "radio");
  27.     print "Receiving station '$t_name' on port $t_port\n";
  28. }
  29.